import 'package:flutter_deer/generated/json/base/json_convert_content.dart';
import 'package:flutter_deer/database/beans/discount/discount_page_item_entity.dart';
import 'dart:math';


CouponBeanList $CouponBeanListFromJson(Map<String, dynamic> json) {
  final CouponBeanList couponBeanList = CouponBeanList();
  final List<CouponBean>? list = (json['list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<CouponBean>(e) as CouponBean).toList();
  if (list != null) {
    couponBeanList.list = list;
  }
  final String? total = jsonConvert.convert<String>(json['total']);
  if (total != null) {
    couponBeanList.total = total;
  }
  return couponBeanList;
}

Map<String, dynamic> $CouponBeanListToJson(CouponBeanList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['list'] = entity.list?.map((v) => v.toJson()).toList();
  data['total'] = entity.total;
  return data;
}

extension CouponBeanListExtension on CouponBeanList {
  CouponBeanList copyWith({
    List<CouponBean>? list,
    String? total,
  }) {
    return CouponBeanList()
      ..list = list ?? this.list
      ..total = total ?? this.total;
  }
}

CouponBean $CouponBeanFromJson(Map<String, dynamic> json) {
  final CouponBean couponBean = CouponBean();
  final int? activityPrice = jsonConvert.convert<int>(json['activityPrice']);
  if (activityPrice != null) {
    couponBean.activityPrice = activityPrice;
  }
  final String? beginDate = jsonConvert.convert<String>(json['beginDate']);
  if (beginDate != null) {
    couponBean.beginDate = beginDate;
  }
  final bool? canOverlay = jsonConvert.convert<bool>(json['canOverlay']);
  if (canOverlay != null) {
    couponBean.canOverlay = canOverlay;
  }
  final bool? canOverlayOther = jsonConvert.convert<bool>(json['canOverlayOther']);
  if (canOverlayOther != null) {
    couponBean.canOverlayOther = canOverlayOther;
  }
  final List<DiscountPageItemConditionList>? conditionList = (json['conditionList'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<DiscountPageItemConditionList>(e) as DiscountPageItemConditionList).toList();
  if (conditionList != null) {
    couponBean.conditionList = conditionList;
  }
  final int? couponAmount = jsonConvert.convert<int>(json['couponAmount']);
  if (couponAmount != null) {
    couponBean.couponAmount = couponAmount;
  }
  final String? couponDenomination = jsonConvert.convert<String>(json['couponDenomination']);
  if (couponDenomination != null) {
    couponBean.couponDenomination = couponDenomination;
  }
  final String? couponDesc = jsonConvert.convert<String>(json['couponDesc']);
  if (couponDesc != null) {
    couponBean.couponDesc = couponDesc;
  }
  final String? couponName = jsonConvert.convert<String>(json['couponName']);
  if (couponName != null) {
    couponBean.couponName = couponName;
  }
  final int? couponNum = jsonConvert.convert<int>(json['couponNum']);
  if (couponNum != null) {
    couponBean.couponNum = couponNum;
  }
  final int? couponStatus = jsonConvert.convert<int>(json['couponStatus']);
  if (couponStatus != null) {
    couponBean.couponStatus = couponStatus;
  }
  final String? couponType = jsonConvert.convert<String>(json['couponType']);
  if (couponType != null) {
    couponBean.couponType = couponType;
  }
  final String? couponUnit = jsonConvert.convert<String>(json['couponUnit']);
  if (couponUnit != null) {
    couponBean.couponUnit = couponUnit;
  }
  final int? couponUseNum = jsonConvert.convert<int>(json['couponUseNum']);
  if (couponUseNum != null) {
    couponBean.couponUseNum = couponUseNum;
  }
  final int? deductionAmount = jsonConvert.convert<int>(json['deductionAmount']);
  if (deductionAmount != null) {
    couponBean.deductionAmount = deductionAmount;
  }
  final int? discountAmount = jsonConvert.convert<int>(json['discountAmount']);
  if (discountAmount != null) {
    couponBean.discountAmount = discountAmount;
  }
  final int? discountMaxAmount = jsonConvert.convert<int>(json['discountMaxAmount']);
  if (discountMaxAmount != null) {
    couponBean.discountMaxAmount = discountMaxAmount;
  }
  final String? endDate = jsonConvert.convert<String>(json['endDate']);
  if (endDate != null) {
    couponBean.endDate = endDate;
  }
  final int? maxQuantity = jsonConvert.convert<int>(json['maxQuantity']);
  if (maxQuantity != null) {
    couponBean.maxQuantity = maxQuantity;
  }
  final String? mchCouponId = jsonConvert.convert<String>(json['mchCouponId']);
  if (mchCouponId != null) {
    couponBean.mchCouponId = mchCouponId;
  }
  final String? memberCouponId = jsonConvert.convert<String>(json['memberCouponId']);
  if (memberCouponId != null) {
    couponBean.memberCouponId = memberCouponId;
  }
  final int? overlayLimit = jsonConvert.convert<int>(json['overlayLimit']);
  if (overlayLimit != null) {
    couponBean.overlayLimit = overlayLimit;
  }
  final int? promotionsMode = jsonConvert.convert<int>(json['promotionsMode']);
  if (promotionsMode != null) {
    couponBean.promotionsMode = promotionsMode;
  }
  final int? promotionsType = jsonConvert.convert<int>(json['promotionsType']);
  if (promotionsType != null) {
    couponBean.promotionsType = promotionsType;
  }
  final int? quantityLimit = jsonConvert.convert<int>(json['quantityLimit']);
  if (quantityLimit != null) {
    couponBean.quantityLimit = quantityLimit;
  }
  final int? remainDays = jsonConvert.convert<int>(json['remainDays']);
  if (remainDays != null) {
    couponBean.remainDays = remainDays;
  }
  final String? rowNum = jsonConvert.convert<String>(json['rowNum']);
  if (rowNum != null) {
    couponBean.rowNum = rowNum;
  }
  final bool? selected = jsonConvert.convert<bool>(json['selected']);
  if (selected != null) {
    couponBean.selected = selected;
  }
  final int? superpositionLimit = jsonConvert.convert<int>(json['superpositionLimit']);
  if (superpositionLimit != null) {
    couponBean.superpositionLimit = superpositionLimit;
  }
  final String? thresholdDesc = jsonConvert.convert<String>(json['thresholdDesc']);
  if (thresholdDesc != null) {
    couponBean.thresholdDesc = thresholdDesc;
  }
  return couponBean;
}

Map<String, dynamic> $CouponBeanToJson(CouponBean entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['activityPrice'] = entity.activityPrice;
  data['beginDate'] = entity.beginDate;
  data['canOverlay'] = entity.canOverlay;
  data['canOverlayOther'] = entity.canOverlayOther;
  data['conditionList'] = entity.conditionList?.map((v) => v.toJson()).toList();
  data['couponAmount'] = entity.couponAmount;
  data['couponDenomination'] = entity.couponDenomination;
  data['couponDesc'] = entity.couponDesc;
  data['couponName'] = entity.couponName;
  data['couponNum'] = entity.couponNum;
  data['couponStatus'] = entity.couponStatus;
  data['couponType'] = entity.couponType;
  data['couponUnit'] = entity.couponUnit;
  data['couponUseNum'] = entity.couponUseNum;
  data['deductionAmount'] = entity.deductionAmount;
  data['discountAmount'] = entity.discountAmount;
  data['discountMaxAmount'] = entity.discountMaxAmount;
  data['endDate'] = entity.endDate;
  data['maxQuantity'] = entity.maxQuantity;
  data['mchCouponId'] = entity.mchCouponId;
  data['memberCouponId'] = entity.memberCouponId;
  data['overlayLimit'] = entity.overlayLimit;
  data['promotionsMode'] = entity.promotionsMode;
  data['promotionsType'] = entity.promotionsType;
  data['quantityLimit'] = entity.quantityLimit;
  data['remainDays'] = entity.remainDays;
  data['rowNum'] = entity.rowNum;
  data['selected'] = entity.selected;
  data['superpositionLimit'] = entity.superpositionLimit;
  data['thresholdDesc'] = entity.thresholdDesc;
  return data;
}

extension CouponBeanExtension on CouponBean {
  CouponBean copyWith({
    int? activityPrice,
    String? beginDate,
    bool? canOverlay,
    bool? canOverlayOther,
    List<DiscountPageItemConditionList>? conditionList,
    int? couponAmount,
    String? couponDenomination,
    String? couponDesc,
    String? couponName,
    int? couponNum,
    int? couponStatus,
    String? couponType,
    String? couponUnit,
    int? couponUseNum,
    int? deductionAmount,
    int? discountAmount,
    int? discountMaxAmount,
    String? endDate,
    int? maxQuantity,
    String? mchCouponId,
    String? memberCouponId,
    int? overlayLimit,
    int? promotionsMode,
    int? promotionsType,
    int? quantityLimit,
    int? remainDays,
    String? rowNum,
    bool? selected,
    int? superpositionLimit,
    String? thresholdDesc,
  }) {
    return CouponBean()
      ..activityPrice = activityPrice ?? this.activityPrice
      ..beginDate = beginDate ?? this.beginDate
      ..canOverlay = canOverlay ?? this.canOverlay
      ..canOverlayOther = canOverlayOther ?? this.canOverlayOther
      ..conditionList = conditionList ?? this.conditionList
      ..couponAmount = couponAmount ?? this.couponAmount
      ..couponDenomination = couponDenomination ?? this.couponDenomination
      ..couponDesc = couponDesc ?? this.couponDesc
      ..couponName = couponName ?? this.couponName
      ..couponNum = couponNum ?? this.couponNum
      ..couponStatus = couponStatus ?? this.couponStatus
      ..couponType = couponType ?? this.couponType
      ..couponUnit = couponUnit ?? this.couponUnit
      ..couponUseNum = couponUseNum ?? this.couponUseNum
      ..deductionAmount = deductionAmount ?? this.deductionAmount
      ..discountAmount = discountAmount ?? this.discountAmount
      ..discountMaxAmount = discountMaxAmount ?? this.discountMaxAmount
      ..endDate = endDate ?? this.endDate
      ..maxQuantity = maxQuantity ?? this.maxQuantity
      ..mchCouponId = mchCouponId ?? this.mchCouponId
      ..memberCouponId = memberCouponId ?? this.memberCouponId
      ..overlayLimit = overlayLimit ?? this.overlayLimit
      ..promotionsMode = promotionsMode ?? this.promotionsMode
      ..promotionsType = promotionsType ?? this.promotionsType
      ..quantityLimit = quantityLimit ?? this.quantityLimit
      ..remainDays = remainDays ?? this.remainDays
      ..rowNum = rowNum ?? this.rowNum
      ..selected = selected ?? this.selected
      ..superpositionLimit = superpositionLimit ?? this.superpositionLimit
      ..thresholdDesc = thresholdDesc ?? this.thresholdDesc;
  }
}

DiscountPageItemConditionList $DiscountPageItemConditionListFromJson(Map<String, dynamic> json) {
  final DiscountPageItemConditionList discountPageItemConditionList = DiscountPageItemConditionList();
  final String? condition = jsonConvert.convert<String>(json['condition']);
  if (condition != null) {
    discountPageItemConditionList.condition = condition;
  }
  final String? fieldName = jsonConvert.convert<String>(json['fieldName']);
  if (fieldName != null) {
    discountPageItemConditionList.fieldName = fieldName;
  }
  final int? minValue = jsonConvert.convert<int>(json['minValue']);
  if (minValue != null) {
    discountPageItemConditionList.minValue = minValue;
  }
  return discountPageItemConditionList;
}

Map<String, dynamic> $DiscountPageItemConditionListToJson(DiscountPageItemConditionList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['condition'] = entity.condition;
  data['fieldName'] = entity.fieldName;
  data['minValue'] = entity.minValue;
  return data;
}

extension DiscountPageItemConditionListExtension on DiscountPageItemConditionList {
  DiscountPageItemConditionList copyWith({
    String? condition,
    String? fieldName,
    int? minValue,
  }) {
    return DiscountPageItemConditionList()
      ..condition = condition ?? this.condition
      ..fieldName = fieldName ?? this.fieldName
      ..minValue = minValue ?? this.minValue;
  }
}